//删除学生的处理函数
//道如数据库连接
const db = require('../db/index')
module.exports.delete = (req, res) => {
  const userInfo = req.body
  const sqlStr = 'delete from Student where Student.id=?'
  db.query(sqlStr, userInfo.id, (err, reslut) => {
    if (err) {
      return res.send({
        status: 1,
        message: '删除失败'
      })
    }
    if (reslut.affectedRows === 0) {
      return res.send({
        status: 403,
        message: '找不到该学生或已被删除',
      })
    }
    if (reslut.affectedRows > 0) {
      return res.send({
        status: 200,
        message: '删除成功',
        data: userInfo
      })
    }
  })
}